package com.example.rouroudate.util

import android.util.Log
import com.example.rouroudate.ui.home.ui.CircleDate
import java.util.*
import kotlin.math.abs

object TimeUtils {
    const val TAG = "TimeUtils"

    const val YEAR = 0
    const val MONTH = 1
    const val DAY = 2

    fun getDateSize(c1: CircleDate, c2: CircleDate): Int {
        setHourToZero(c1)
        setHourToZero(c2)
        val time = abs(c1.beginDate.time.time - c2.beginDate.time.time) / (24 * 3600 * 1000)
        return time.toInt()
    }

    private fun setHourToZero(circleDate: CircleDate) {
        circleDate.beginDate[Calendar.HOUR] = 0
        circleDate.beginDate[Calendar.MINUTE] = 0
        circleDate.beginDate[Calendar.SECOND] = 0
    }

    fun isGreatThanToday(circleDate: CircleDate): Boolean {
        val todayDate = Calendar.getInstance()
        todayDate[Calendar.HOUR] = 23
        todayDate[Calendar.MINUTE] = 59
        todayDate[Calendar.SECOND] = 59
        return circleDate.beginDate.after(todayDate)
    }
}